from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By

test=webdriver.Chrome()
test.get("https://www.kugou.com/")
test.maximize_window()
sleep(3)
#定位登录按钮
test.find_element(By.XPATH,"//div[text()='登录']").click()
# test.find_element(By.CSS_SELECTOR,".cmhead1_d5._login").click()
sleep(3)
#切换成手机号登录
test.switch_to.frame("loginIframe")
test.find_element(By.CLASS_NAME,"lgn_account").click()
# test.find_element(By.ID,"j_kg_popup_switch").click()
sleep(3)
#输入手机号
test.find_element(By.CSS_SELECTOR,".kg_popup_txt_ipt").send_keys("15522020590")
#sleep(3)
#验证码
test.find_element(By.ID,"KgPopupCode").send_keys("3456")
#点击登录
test.find_element(By.CLASS_NAME,"kg_popup_login_btn").click()
sleep(2)
#返回上一层页面
test.switch_to.parent_frame()
#退出登录页面
test.find_element(By.ID,"KgPopupLoginCloseBtn").click()
sleep(3)
test.quit()